home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 472 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.5 KB

  1. Path: taumet.Eng.Sun.COM!clamage
  2. From: clamage@Eng.sun.com (Steve Clamage)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Type conflicts
  5. Date: 23 Feb 1996 22:38:27 GMT
  6. Organization: Sun Microsystems Inc.
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <4gl8f4$aum@engnews1.Eng.Sun.COM>
  9. References: <ye7bumpal7p.fsf@pil.idt.unit.no>
  10. Reply-To: clamage@Eng.sun.com
  11. NNTP-Posting-Host: taumet.eng.sun.com
  12. Content-Type: text
  13. X-Nntp-Posting-Host: taumet.eng.sun.com
  14. Content-Length: 740
  15. X-Lines: 20
  16. Originator: clamage@taumet.Eng.Sun.COM
  17.  
  18. In article fsf@pil.idt.unit.no, erikoest@idt.unit.no (Erik Oestlyngen) writes:
  19. >
  20. >When i define two different structs with the same name in two
  21. >different files, my compiler don't complain. I can then use the struct
  22. >as input parameter for a function in one file, and from the other send
  23. >the different struct into the function. The function will then get
  24. >an other input type than it expects.
  25.  
  26. >What does the ansi-C++ standard say about this?
  27.  
  28. The One-Definition Rule says in part that two types with the same name
  29. in the same scope must have the same definition.
  30.  
  31. Your code violates the One-Definition Rule, and has undefined behavior.
  32. The compiler is not required to diagnose the error.
  33.  
  34. ---
  35. Steve Clamage, stephen.clamage@eng.sun.com
  36.  
  37.  
  38. [ To submit articles: Try just posting with your newsreader.
  39.               If that fails, use mailto:std-c++@ncar.ucar.edu
  40.   FAQ:    http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  41.   Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  42.   Comments? mailto:std-c++-request@ncar.ucar.edu
  43. ]
  44.